using System;
using System.Diagnostics;
using System.Net;
using Game500.ClientServerCommon.Src;

namespace Game500.Client.Src
{
#if WINDOWS || XBOX
  internal static class Program
  {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    private static void Main(string[] args)
    {
      int port;
      string name;
      IPAddress address = IPAddress.Loopback;
      try
      {
        var bag = new ArgumentBag(args);
        name = bag.GetValue("-n", string.Format("Player{0}", Process.GetCurrentProcess().Id));
        port = int.Parse(bag.GetValue("-p", "5050"));
      }
      catch (Exception e)
      {
        Console.WriteLine("ERROR: {0}", e);
        return;
      }

      var endpoint = new IPEndPoint(address, port);

      using (var game = new MainGame(endpoint, name, new BaseMapManager()))
      {
        game.Run();
      }
    }
  }
#endif
}